package org.example.maven.utils;

import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.util.UUID;

public class uploadImg {
    public static final String FILESAVEPATH="D:\\vue\\bowuguanTest\\src\\assets\\image\\";
    public static String UploadImg(MultipartFile file) throws IOException {
        //后缀
        String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
        String newFileName= UUID.randomUUID().toString().replaceAll("-", "") + suffix;
        //创建这个新文件
        file.transferTo(new File(FILESAVEPATH + newFileName));
        return newFileName;
    }
}
